package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.TransportTableChineseEnglish;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2019-05-19 00:26:11
 */
@Repository
public class TransportTableChineseEnglishDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(TransportTableChineseEnglishDao.class);

    public TransportTableChineseEnglish insert(final TransportTableChineseEnglish transportTableChineseEnglish) {
        insert("TransportTableChineseEnglish.insert", transportTableChineseEnglish);
        return transportTableChineseEnglish;
    }

    public Boolean updateInfoById(final TransportTableChineseEnglish transportTableChineseEnglish) {
        return update("TransportTableChineseEnglish.updateInfoById", transportTableChineseEnglish) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("TransportTableChineseEnglish.updateInfoByQuery", query) > 0;
    }

    public TransportTableChineseEnglish selectById(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return queryForObject("TransportTableChineseEnglish.selectById", query);
    }

    public List<TransportTableChineseEnglish> selectByQuery(final Query query) {
        return queryForList("TransportTableChineseEnglish.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("TransportTableChineseEnglish.countByQuery", query);
    }

    public Boolean deleteById(final Integer id) {
        TransportTableChineseEnglish transportTableChineseEnglish = new TransportTableChineseEnglish();
        transportTableChineseEnglish.setDeleteFlag(1);
        transportTableChineseEnglish.setId(id);

        return update("TransportTableChineseEnglish.updateInfoById", transportTableChineseEnglish) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("TransportTableChineseEnglish.deleteById", query) > 0;
    }
}